<template>
  <AppLayout ref="appLayoutRef">
    <!-- 左侧面板 -->
    <div class="left-panel">
      <div class="panel-container">
        <div class="panel-header">
          <div class="header-animation" :style="{ backgroundImage: `url(${appLayoutRef?.shortImageUrl})` }"></div>
          <el-icon><DataLine /></el-icon>
          <span>作物生长状态分布</span>
        </div>
        <div class="panel-content">
          <LeftTop />
        </div>
      </div>
      <div class="panel-container">
        <div class="panel-header">
          <div class="header-animation" :style="{ backgroundImage: `url(${appLayoutRef?.shortImageUrl})` }"></div>
          <el-icon><TrendCharts /></el-icon>
          <span>土壤湿度监测</span>
        </div>
        <div class="panel-content">
          <LeftMiddle />
        </div>
      </div>
      <div class="panel-container">
        <div class="panel-header">
          <div class="header-animation" :style="{ backgroundImage: `url(${appLayoutRef?.shortImageUrl})` }"></div>
          <el-icon><Warning /></el-icon>
          <span>病虫害预警</span>
        </div>
        <div class="panel-content">
          <LeftBottom />
        </div>
      </div>
    </div>

    <!-- 中间面板 -->
    <div class="center-panel">
      <div class="panel-container">
        <div class="panel-header">
          <div class="header-animation" :style="{ backgroundImage: `url(${appLayoutRef?.longImageUrl})` }"></div>
          <el-icon><MapLocation /></el-icon>
          <span>农场监测地图</span>
        </div>
        <div class="panel-content">
          <CenterTop />
        </div>
      </div>
      <div class="panel-container">
        <div class="panel-header">
          <div class="header-animation" :style="{ backgroundImage: `url(${appLayoutRef?.longImageUrl})` }"></div>
          <el-icon><Setting /></el-icon>
          <span>数据展示板</span>
        </div>
        <div class="panel-content">
          <CenterBottom />
        </div>
      </div>
    </div>

    <!-- 右侧面板 -->
    <div class="right-panel">
      <div class="panel-container">
        <div class="panel-header">
          <div class="header-animation" :style="{ backgroundImage: `url(${appLayoutRef?.shortImageUrl})` }"></div>
          <el-icon><Monitor /></el-icon>
          <span>环境监测数据</span>
        </div>
        <div class="panel-content">
          <RightTop />
        </div>
      </div>
      <div class="panel-container">
        <div class="panel-header">
          <div class="header-animation" :style="{ backgroundImage: `url(${appLayoutRef?.shortImageUrl})` }"></div>
          <el-icon><Document /></el-icon>
          <span>长势排行榜</span>
        </div>
        <div class="panel-content">
          <RightMiddle />
        </div>
      </div>
      <div class="panel-container">
        <div class="panel-header">
          <div class="header-animation" :style="{ backgroundImage: `url(${appLayoutRef?.shortImageUrl})` }"></div>
          <el-icon><Warning /></el-icon>
          <span>实时警告信息</span>
        </div>
        <div class="panel-content">
          <RightBottom />
        </div>
      </div>
    </div>
  </AppLayout>
</template>

<script setup lang="ts">
import { ref } from 'vue'
import {
  DataLine,
  TrendCharts,
  MapLocation,
  Warning,
  Setting,
  Monitor,
  Document
} from '@element-plus/icons-vue'
import AppLayout from '@/components/Layout/AppLayout.vue'

// 导入子组件
import LeftTop from './left/LeftTop.vue'
import LeftMiddle from './left/LeftMiddle.vue'
import LeftBottom from './left/LeftBottom.vue'
import CenterTop from './center/CenterTop.vue'
import CenterBottom from './center/CenterBottom.vue'
import RightTop from './right/RightTop.vue'
import RightMiddle from './right/RightMiddle.vue'
import RightBottom from './right/RightBottom.vue'

const appLayoutRef = ref()
</script>

<style scoped>
.left-panel, .center-panel, .right-panel {
  display: flex;
  flex-direction: column;
  gap: 10px;
  height: 100%;
}

.left-panel, .right-panel {
  width: 25%;
}

.center-panel {
  width: 50%;
}

.center-panel .panel-container:first-child {
  flex: 4;
}

.center-panel .panel-container:last-child {
  flex: 1;
}

.panel-container {
  position: relative;
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  background: linear-gradient(180deg, rgba(18, 161, 127, 0.1) 0%, rgba(18, 161, 127, .45) 100%);
  backdrop-filter: blur(5px);
  box-shadow: 0 0 20px rgba(18, 161, 127, 0.1);
  overflow: hidden;
}

.panel-header {
  font-size: 1.2rem;
  padding: 12px 0 22px 65px;
  color: #33ffd0;
  text-shadow: 0 0 10px rgba(51, 255, 208, 0.3);
  text-align: left;
  position: relative;
  overflow: hidden;
  height: 50px;
  display: flex;
  align-items: center;
  pointer-events: none;
  flex-shrink: 0;
}

.panel-header .el-icon {
  margin-right: 10px;
  font-size: 20px;
  color: #33ffd0;
  text-shadow: 0 0 10px rgba(51, 255, 208, 0.3);
}

.header-animation {
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 100%;
  height: 200%;
  background-repeat: no-repeat;
  background-size: 100% auto;
  background-position: center;
  opacity: 1;
  z-index: -1;
}

.panel-header span {
  position: relative;
  z-index: 1;
  pointer-events: none;
}

.panel-header::after {
  content: '';
  position: absolute;
  right: 0;
  top: 33%;
  width: 40%;
  height: 2px;
  background: linear-gradient(90deg,
    rgba(51, 255, 208, 0.5),
    rgba(51, 255, 208, 0)
  );
  z-index: 1;
}

.panel-content {
  position: relative;
  z-index: 1;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

:deep(.panel) {
  flex: 1;
  min-height: 0;
}
</style> 